﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Teacher
    {
        // [Description("ID")]
            public  long ID{get;set;}
        [Description("Mã giáo viên")]
            public string Code{get;set;}
        [Description("Tên giáo viên")]
            public string Name{get;set;}
        [Description("Địa chỉ")]
            public string Address{get;set;}
        [Description("Điện thoại")]
            public string Phone{get;set;}
        [Description("Email")]
            public string Email{get;set;}
        [Description("Giới tính")]
            public string Sex { get; set; }
        [Description("Số CMND")]
            public string IndentifyNumber{get;set;}
        [Description("Ghi chú")]
            public string Description{get;set;}
        [Description("Sử dụng")]
            public bool Active{get;set;}
        public bool IsDeleted { get; set; }
         
        public Teacher()
        {       
                            Code ="";   
                            Name ="";   
                            Address ="";   
                            Phone ="";   
                            Email ="";   
                            IndentifyNumber ="";
                            Sex = "";
                            Description ="";
                            IsDeleted = false;
        }
        
       static Teacher DynamicCast<T>(object row_data, object row_header) where T : Teacher
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           Teacher ret = new Teacher();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                      case  "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "Code":
                        ret.Code = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Name":
                        ret.Name = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Address":
                        ret.Address = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Phone":
                        ret.Phone = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Email":
                        ret.Email = ConvertObject.ToString(dt[column]);
                       break;
                      case  "IndentifyNumber":
                        ret.IndentifyNumber = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Description":
                        ret.Description = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Active":
                        ret.Active = ConvertObject.ToBool(dt[column]);
                       break;
                      case "Sex":
                       ret.Sex = ConvertObject.ToString(dt[column]);
                       break;
                   case "IsDeleted":
                       ret.IsDeleted = ConvertObject.ToBool(dt[column]);
                       break;
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}
